package org.jivesoftware.smack;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import org.jivesoftware.smack.packet.IQ.Type;
import org.jivesoftware.smack.packet.RosterPacket;
import org.jivesoftware.smack.packet.RosterPacket.Item;
import org.jivesoftware.smack.packet.RosterPacket.ItemStatus;
import org.jivesoftware.smack.packet.RosterPacket.ItemType;

public class RosterEntry
{
  private String user;
  private String name;
  private RosterPacket.ItemType type;
  private RosterPacket.ItemStatus status;
  private final Roster roster;
  private final Connection connection;

  RosterEntry(String paramString1, String paramString2, RosterPacket.ItemType paramItemType, RosterPacket.ItemStatus paramItemStatus, Roster paramRoster, Connection paramConnection)
  {
    this.user = paramString1;
    this.name = paramString2;
    this.type = paramItemType;
    this.status = paramItemStatus;
    this.roster = paramRoster;
    this.connection = paramConnection;
  }

  public String getUser()
  {
    return this.user;
  }

  public String getName()
  {
    return this.name;
  }

  public void setName(String paramString)
  {
    if ((paramString != null) && (paramString.equals(this.name)))
      return;
    this.name = paramString;
    RosterPacket localRosterPacket = new RosterPacket();
    localRosterPacket.setType(IQ.Type.SET);
    localRosterPacket.addRosterItem(toRosterItem(this));
    this.connection.sendPacket(localRosterPacket);
  }

  void updateState(String paramString, RosterPacket.ItemType paramItemType, RosterPacket.ItemStatus paramItemStatus)
  {
    this.name = paramString;
    this.type = paramItemType;
    this.status = paramItemStatus;
  }

  public Collection<RosterGroup> getGroups()
  {
    ArrayList localArrayList = new ArrayList();
    Iterator localIterator = this.roster.getGroups().iterator();
    while (localIterator.hasNext())
    {
      RosterGroup localRosterGroup = (RosterGroup)localIterator.next();
      if (localRosterGroup.contains(this))
        localArrayList.add(localRosterGroup);
    }
    return Collections.unmodifiableCollection(localArrayList);
  }

  public RosterPacket.ItemType getType()
  {
    return this.type;
  }

  public RosterPacket.ItemStatus getStatus()
  {
    return this.status;
  }

  public String toString()
  {
    StringBuilder localStringBuilder = new StringBuilder();
    if (this.name != null)
      localStringBuilder.append(this.name).append(": ");
    localStringBuilder.append(this.user);
    Collection localCollection = getGroups();
    if (!localCollection.isEmpty())
    {
      localStringBuilder.append(" [");
      Iterator localIterator = localCollection.iterator();
      RosterGroup localRosterGroup = (RosterGroup)localIterator.next();
      localStringBuilder.append(localRosterGroup.getName());
      while (localIterator.hasNext())
      {
        localStringBuilder.append(", ");
        localRosterGroup = (RosterGroup)localIterator.next();
        localStringBuilder.append(localRosterGroup.getName());
      }
      localStringBuilder.append("]");
    }
    return localStringBuilder.toString();
  }

  public boolean equals(Object paramObject)
  {
    if (this == paramObject)
      return true;
    if ((paramObject != null) && ((paramObject instanceof RosterEntry)))
      return this.user.equals(((RosterEntry)paramObject).getUser());
    return false;
  }

  public int hashCode()
  {
    return this.user.hashCode();
  }

  public boolean equalsDeep(Object paramObject)
  {
    if (this == paramObject)
      return true;
    if (paramObject == null)
      return false;
    if (getClass() != paramObject.getClass())
      return false;
    RosterEntry localRosterEntry = (RosterEntry)paramObject;
    if (this.name == null)
    {
      if (localRosterEntry.name != null)
        return false;
    }
    else if (!this.name.equals(localRosterEntry.name))
      return false;
    if (this.status == null)
    {
      if (localRosterEntry.status != null)
        return false;
    }
    else if (!this.status.equals(localRosterEntry.status))
      return false;
    if (this.type == null)
    {
      if (localRosterEntry.type != null)
        return false;
    }
    else if (!this.type.equals(localRosterEntry.type))
      return false;
    if (this.user == null)
    {
      if (localRosterEntry.user != null)
        return false;
    }
    else if (!this.user.equals(localRosterEntry.user))
      return false;
    return true;
  }

  static RosterPacket.Item toRosterItem(RosterEntry paramRosterEntry)
  {
    RosterPacket.Item localItem = new RosterPacket.Item(paramRosterEntry.getUser(), paramRosterEntry.getName());
    localItem.setItemType(paramRosterEntry.getType());
    localItem.setItemStatus(paramRosterEntry.getStatus());
    Iterator localIterator = paramRosterEntry.getGroups().iterator();
    while (localIterator.hasNext())
    {
      RosterGroup localRosterGroup = (RosterGroup)localIterator.next();
      localItem.addGroupName(localRosterGroup.getName());
    }
    return localItem;
  }
}

/* Location:           D:\hygieia\userclient\common\libs\easemobchat_2.1.8.jar
 * Qualified Name:     org.jivesoftware.smack.RosterEntry
 * JD-Core Version:    0.6.1
 */